﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		BlogRollService.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 // 
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion

using System;
using Dexter.Core.EventArgs;
using Dexter.Domain.Model;
using Dexter.Domain.Results;
using Dexter.Logger.Contracts;
using Dexter.Repository;
using Dexter.Services;

namespace Dexter.Services.Implementation {
	/// <summary>
	/// 	The implementatio of <see cref = "IBlogRollService" />.
	/// </summary>
	public class BlogRollService : IBlogRollService {
		/// <summary>
		/// 	An instance of a concrete implementation of <see cref = "IBlogRollRepository" />
		/// </summary>
		protected readonly IBlogRollRepository BlogRollRepository;

		/// <summary>
		/// 	The logger
		/// </summary>
		protected readonly ILogger Logger;

		/// <summary>
		/// 	Initializes a new instance of the <see cref = "BlogRollService" /> class.
		/// </summary>
		/// <param name = "logger">The logger.</param>
		/// <param name = "blogRollRepository">The blog roll repository.</param>
		public BlogRollService ( ILogger logger , IBlogRollRepository blogRollRepository ) {
			this.Logger = logger;
			this.BlogRollRepository = blogRollRepository;
		}

		#region IBlogRollService Members

		/// <summary>
		/// 	Return a list of BlogRoll with all properties loaded.
		/// </summary>
		/// <param name = "pageIndex">Index of the page (0 based).</param>
		/// <param name = "pageSize">The number of items to retrieve.</param>
		/// <returns>
		/// 	An concrete implementation of <see cref = "IPagedResult" />. The result will never be null.
		/// </returns>
		public virtual IPagedResult <BlogRoll> GetListPaged ( int pageIndex , int pageSize ) {
			var data = this.GetListPaged ( pageIndex , pageSize , true );

			BlogRollsRetrieved.Raise ( this , new GenericEventArgs <IPagedResult <BlogRoll>> ( data ) );

			return data;
		}

		/// <summary>
		/// 	Return a list of BlogRoll with all properties loaded.
		/// </summary>
		/// <param name = "pageIndex">Index of the page (0 based).</param>
		/// <param name = "pageSize">The number of items to retrieve.</param>
		/// <param name = "enableTracking">if set to <c>true</c> the tracking system of the return object will be enable.</param>
		/// <returns>
		/// 	An concrete implementation of <see cref = "IPagedResult{T}" />. The result will never be null.
		/// </returns>
		public virtual IPagedResult <BlogRoll> GetListPaged ( int pageIndex , int pageSize , bool enableTracking ) {
			var data = BlogRollRepository.GetListPaged ( pageIndex , pageSize , enableTracking );

			BlogRollsRetrieved.Raise ( this , new GenericEventArgs <IPagedResult <BlogRoll>> ( data ) );

			return data;
		}

		/// <summary>
		/// 	This event will raise when a list of <see cref = "BlogRoll" /> will retrieved by the implementation of <see cref = "IBlogRollService.GetListPaged(int,int)" />.
		/// </summary>
		public virtual event EventHandler <GenericEventArgs <IPagedResult <BlogRoll>>> BlogRollsRetrieved;

		#endregion
	}
}
